var http = require('http');

var cunto = 8080

var ip = "127.0.0.1"
var server = http.createServer(function (request, response) {
	response.statusCode = 200;
	response.setHeader("Content-Type","text/html")
		var ext = request.url.substr(request.url.lastIndexOf(".")+1)
		var exts = {
			"html":"text/html",
			"css":"text/css",
			"jpg":"	image/jpeg",
			"js":"text/javascript",
		}
		if (exts[ext] == null) {
			exts[ext] ="text/plain"
		}
		var fs = require("fs");
		var s ='404'
		response.setHeader("Content-Type",exts[ext])
		try{
			 s = fs.readFileSync('.' + request.url )
		}catch(e){

		}
	
		response.write(s);
		response.end()
})
 server.listen(cunto);
console.log('Server running at http://%s:%s/',ip,cunto);